home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / include / sys / RCS / dir.h,v < prev    next >
Text File  |  1990-09-18  |  4KB  |  175 lines

  1. head     1.4;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.4
  10. date     90.09.18.17.20.44;  author kupfer;  state Exp;
  11. branches ;
  12. next     1.3;
  13.  
  14. 1.3
  15. date     89.07.14.09.15.19;  author rab;  state Exp;
  16. branches ;
  17. next     1.2;
  18.  
  19. 1.2
  20. date     88.06.29.14.47.44;  author ouster;  state Exp;
  21. branches ;
  22. next     1.1;
  23.  
  24. 1.1
  25. date     88.06.26.15.43.56;  author ouster;  state Exp;
  26. branches ;
  27. next     ;
  28.  
  29.  
  30. desc
  31. @@
  32.  
  33.  
  34. 1.4
  35. log
  36. @include <sys/types.h> (to get u_long typedef).
  37. @
  38. text
  39. @/*
  40.  * Copyright (c) 1982, 1986 Regents of the University of California.
  41.  * All rights reserved.  The Berkeley software License Agreement
  42.  * specifies the terms and conditions for redistribution.
  43.  *
  44.  *    @@(#)dir.h    7.2 (Berkeley) 12/22/86
  45.  */
  46.  
  47. #ifndef _DIR
  48. #define _DIR
  49.  
  50. #include <sys/types.h>
  51.  
  52. /*
  53.  * A directory consists of some number of blocks of DIRBLKSIZ
  54.  * bytes, where DIRBLKSIZ is chosen such that it can be transferred
  55.  * to disk in a single atomic operation (e.g. 512 bytes on most machines).
  56.  *
  57.  * Each DIRBLKSIZ byte block contains some number of directory entry
  58.  * structures, which are of variable length.  Each directory entry has
  59.  * a struct direct at the front of it, containing its inode number,
  60.  * the length of the entry, and the length of the name contained in
  61.  * the entry.  These are followed by the name padded to a 4 byte boundary
  62.  * with null bytes.  All names are guaranteed null terminated.
  63.  * The maximum length of a name in a directory is MAXNAMLEN.
  64.  *
  65.  * The macro DIRSIZ(dp) gives the amount of space required to represent
  66.  * a directory entry.  Free space in a directory is represented by
  67.  * entries which have dp->d_reclen > DIRSIZ(dp).  All DIRBLKSIZ bytes
  68.  * in a directory block are claimed by the directory entries.  This
  69.  * usually results in the last entry in a directory having a large
  70.  * dp->d_reclen.  When entries are deleted from a directory, the
  71.  * space is returned to the previous entry in the same directory
  72.  * block by increasing its dp->d_reclen.  If the first entry of
  73.  * a directory block is free, then its dp->d_ino is set to 0.
  74.  * Entries other than the first in a directory do not normally have
  75.  * dp->d_ino set to 0.
  76.  */
  77. /* so user programs can just include dir.h */
  78. #if !defined(KERNEL) && !defined(DEV_BSIZE)
  79. #define    DEV_BSIZE    512
  80. #endif
  81. #define DIRBLKSIZ    DEV_BSIZE
  82. #define    MAXNAMLEN    255
  83.  
  84. struct    direct {
  85.     u_long    d_ino;            /* inode number of entry */
  86.     u_short    d_reclen;        /* length of this record */
  87.     u_short    d_namlen;        /* length of string in d_name */
  88.     char    d_name[MAXNAMLEN + 1];    /* name must be no longer than this */
  89. };
  90.  
  91. /*
  92.  * The DIRSIZ macro gives the minimum record length which will hold
  93.  * the directory entry.  This requires the amount of space in struct direct
  94.  * without the d_name field, plus enough space for the name with a terminating
  95.  * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
  96.  */
  97. #undef DIRSIZ
  98. #define DIRSIZ(dp) \
  99.     ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
  100.  
  101. #ifndef KERNEL
  102. /*
  103.  * Definitions for library routines operating on directories.
  104.  */
  105. typedef struct _dirdesc {
  106.     int    dd_fd;
  107.     long    dd_loc;
  108.     long    dd_size;
  109.     char    dd_buf[DIRBLKSIZ];
  110. } DIR;
  111.  
  112. #define dirfd(dirp)    ((dirp)->dd_fd)
  113.  
  114. #ifndef NULL
  115. #define NULL 0
  116. #endif
  117. extern    DIR *opendir();
  118. extern    struct direct *readdir();
  119. extern    long telldir();
  120. extern    void seekdir();
  121. #define rewinddir(dirp)    seekdir((dirp), (long)0)
  122. extern    void closedir();
  123. #endif
  124.  
  125. #endif /* _DIR */
  126. @
  127.  
  128.  
  129. 1.3
  130. log
  131. @*** empty log message ***
  132. @
  133. text
  134. @d12 2
  135. @
  136.  
  137.  
  138. 1.2
  139. log
  140. @Add ifdefs to prevent files from being included multiple times.
  141. @
  142. text
  143. @d85 1
  144. a85 1
  145. #endif _DIR
  146. @
  147.  
  148.  
  149. 1.1
  150. log
  151. @Initial revision
  152. @
  153. text
  154. @d9 3
  155. d85 1
  156. a85 17
  157. #ifdef KERNEL
  158. /*
  159.  * Template for manipulating directories.
  160.  * Should use struct direct's, but the name field
  161.  * is MAXNAMLEN - 1, and this just won't do.
  162.  */
  163. struct dirtemplate {
  164.     u_long    dot_ino;
  165.     short    dot_reclen;
  166.     short    dot_namlen;
  167.     char    dot_name[4];        /* must be multiple of 4 */
  168.     u_long    dotdot_ino;
  169.     short    dotdot_reclen;
  170.     short    dotdot_namlen;
  171.     char    dotdot_name[4];        /* ditto */
  172. };
  173. #endif
  174. @
  175.